package uz.edo.app.admin.departmentPages;

import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
import uz.edo.app.admin.AdminPage;
import uz.edo.db.bean.Department;
import uz.edo.db.manager.DepartmentManager;

/**
 * Created by IntelliJ IDEA.
 * User: said
 * Date: 1/23/12
 * Time: 5:42 AM
 * To change this template use File | Settings | File Templates.
 */
public class DepartmentEdit extends AdminPage{

    private DepartmentManager manager = DepartmentManager.getInstance();

    public DepartmentEdit(final Department department) {
        CompoundPropertyModel model = new CompoundPropertyModel(department);
        Form form = new Form("form",model){
            @Override
            protected void onSubmit() {
                try {
                    manager.saveOrUpdate(department);
                    setResponsePage(DepartmentListView.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        add(form);
        form.add(new TextField("nameUz"));
        form.add(new TextField("nameRu"));
    }
}
